package com.zl.tby.vo.exp;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.zl.tby.core.base.bean.OptionType;
import com.zl.tby.core.base.util.ToolsUtil;
import com.zl.tby.model.TbyVillageInfo;
import com.zl.tby.vo.TbyVillageInfoForm;
import lombok.Data;
import org.noear.solon.validation.annotation.Length;
import org.noear.solon.validation.annotation.NotBlank;
import org.noear.solon.validation.annotation.NotNull;
import org.noear.wood.utils.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 社区共管 excel
 * @author sunjiaxing
 * @version 1.0
 * @since 2024/8/22 00:28
 */
@HeadRowHeight(20)
@ContentRowHeight(15)
@Data
public class TbyVillageInfoExportExcel {

    @ExcelProperty(value = "村庄名称", index = 0)
    @ColumnWidth(15)
    private String villageName;
    @ExcelProperty(value = "类型", index = 1)
    @ColumnWidth(15)
    private String villageType;
    @ExcelProperty(value = "户籍人口", index = 2)
    @ColumnWidth(15)
    private Long registeredPopulation;
    @ExcelProperty(value = "常住人口", index = 3)
    @ColumnWidth(15)
    private Long permanentPopulation;
    @ExcelProperty(value = "劳动力", index = 4)
    @ColumnWidth(15)
    private Long labourForce;
    @ExcelProperty(value = "经度", index = 5)
    @ColumnWidth(15)
    private String longitude;
    @ExcelProperty(value = "纬度", index = 6)
    @ColumnWidth(15)
    private String latitude;

    public TbyVillageInfoExportExcel(TbyVillageInfo form) {
        this.villageName = form.getVillageName();
        if (form.getVillageType() != null) {
            this.villageType = form.getVillageType().intValue() == 0 ? "行政村" : "自然村";
        }
        this.registeredPopulation = form.getRegisteredPopulation();
        this.permanentPopulation = form.getPermanentPopulation();
        this.labourForce = form.getLabourForce();
        this.longitude = form.getLongitude();
        this.latitude = form.getLatitude();
    }

    public static List<TbyVillageInfoExportExcel> createList(List<TbyVillageInfo> dbList) {
        List<TbyVillageInfoExportExcel> dataList = new ArrayList<>();
        if (dbList != null) {
            dbList.forEach(item -> {
                dataList.add(new TbyVillageInfoExportExcel(item));
            });
        }
        return dataList;
    }
}
